import { defineStore } from "pinia";

const key={
    project:'jz-app-project'
}

export const useProjectStore = defineStore({
    id:'project',
    state:()=>({
        project:uni.getStorageSync(key.project) ||-1
    }),
    actions:{
        clearProject(){
            this.project={}
            uni.removeStorage({
            	key:key.project
            })
        },
        setProject(project){
            this.project=project
			uni.setStorage({
				key:key.project,
				data:this.project
			})
        },
        getProject(){
			this.project=uni.getStorageSync(key.project) ||''
            return this.project
        },
        isProjectAdmin(){
            return this.project.projectUser && this.project.projectUser.isAdmin=='Y'
        }
    }
})